/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.max.oti.system.bean.sgt;

import com.max.oti.system.model.Bachilor;
import com.max.oti.system.service.interfac.IBachilorService;
import com.max.oti.system.util.FacesUtil;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author max
 */
@ManagedBean
@ViewScoped
public class TrackingBachilorBean {
    
    @ManagedProperty("#{bachilorService}")
    IBachilorService bachilorService;
    
    private Bachilor bachilor;
    
    private List<Bachilor> listBachilor;
    private List<Bachilor> listBachilorFilter;
    
    @PostConstruct
    public void initCollection() {
        try {
            listBachilor = bachilorService.listHQL("from Bachilor b where state='COMPLETADO'");
        } catch (Exception ex) {
            Logger.getLogger(TrackingBachilorBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void editBachilor(){
        try {
            bachilorService.update(bachilor);
            FacesUtil.addMessage("Editado Con Exito.", null, FacesMessage.SEVERITY_INFO);
            FacesUtil.getRequestContext().execute("editBachilor.hide()");
        } catch (Exception ex) {
            FacesUtil.addMessage("ERROR AL GUARDAR", null, FacesMessage.SEVERITY_ERROR);
            Logger.getLogger(TrackingBachilorBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public List<Bachilor> getListBachilor() {
        return listBachilor;
    }

    public void setListBachilor(List<Bachilor> listBachilor) {
        this.listBachilor = listBachilor;
    }

    public void setBachilorService(IBachilorService bachilorService) {
        this.bachilorService = bachilorService;
    }

    public Bachilor getBachilor() {
        return bachilor;
    }

    public void setBachilor(Bachilor bachilor) {
        this.bachilor = bachilor;
    }

    public List<Bachilor> getListBachilorFilter() {
        return listBachilorFilter;
    }

    public void setListBachilorFilter(List<Bachilor> listBachilorFilter) {
        this.listBachilorFilter = listBachilorFilter;
    }
    
    
}
